package org.xiaoyu.server;


import com.carrotsearch.sizeof.RamUsageEstimator;
import com.xiaoyu.stereotype.Component;
import org.xiaoyu.api.BigObject;
import org.xiaoyu.api.HelloService;
import org.xiaoyu.api.pojo.User;
import org.xiaoyu.api.pojo.UserService;
import org.xiaoyu.rpc.common.annotations.RpcService;

import java.util.concurrent.CompletableFuture;


/**
 * Created By Have
 * 2021/7/15 14:58
 */
@RpcService(interfaceClass = HelloService.class, serviceName = "hello", path = "/hello", weight = 2)
@Component
public class HelloServiceImpl implements HelloService {
    private final BigObject bigObject = new BigObject();

    @Override
    public Object sayHello() {
//        try {
//            Thread.sleep(50);
//        } catch (InterruptedException e) {
//        }
        UserService userService = new UserService();
        return userService.get();
//        return "1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1" +
//                "KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTe" +
//                "st1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1" +
//                "KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStrin" +
//                "gForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KB" +
//                "StringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1" +
//                "KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForT" +
//                "est1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBString" +
//                "ForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBSt" +
//                "ringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1K" +
//                "BStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTes" +
//                "t1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForT" +
//                "est1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringFo" +
//                "rTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringF" +
//                "orTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringF" +
//                "orTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringFo" +
//                "rTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringFor" +
//                "Test1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringFor" +
//                "Test1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForT" +
//                "est1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTes" +
//                "t1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1K" +
//                "BStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBSt" +
//                "ringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStrin" +
//                "gForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringFor" +
//                "Test1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest" +
//                "1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBStringForTest1KBSt" +
//                "ringForTest1KBStringForTest1KBStringForTest";
    }

    @Override
    public String sayHey() {
        return "Hey Rpc";
    }

    public static void main(String[] args) {
        long start = System.currentTimeMillis();
        for (int i = 0; i < 50000; i++) {
//            UserService userService = new UserService();
//            User user = userService.get();
//            System.out.println(RamUsageEstimator.sizeOf(user));
        }
        
        System.out.println("Time Consuming:" + (System.currentTimeMillis() - start));
    }
}
